﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;


namespace SDLITS.Web.Driver
{
    /// <summary>
    /// FingerHelper 的摘要说明
    /// </summary>
    public class FingerHelper : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            Base64StringToImage(context.Request["str"], context.Request["id"]);
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }


        //base64编码的文本 转为    图片
        private void Base64StringToImage(string inputStr,string IdNumber)
        {
            try
            {
                byte[] arr = Convert.FromBase64String(inputStr);
                MemoryStream ms = new MemoryStream(arr);
                Bitmap bmp = new Bitmap(ms);

                bmp.Save("/img/FingerShot/" + IdNumber + ".bmp", ImageFormat.Bmp);

                //bmp.Save(txtFileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                //bmp.Save(txtFileName + ".bmp", ImageFormat.Bmp);
                //bmp.Save(txtFileName + ".gif", ImageFormat.Gif);
                //bmp.Save(txtFileName + ".png", ImageFormat.Png);
                ms.Close();
                //MessageBox.Show("转换成功！");
            }
            catch (Exception ex)
            {
                
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}